/*!
 * Ext JS Library 3.3.0
 * Copyright(c) 2006-2010 Ext JS, Inc.
 * licensing@extjs.com
 * http://www.extjs.com/license
 */

Ext.onReady(function() {
	

		var device_store = new Ext.data.Store({
        proxy: new Ext.data.HttpProxy({
            url: '/mobile/get_locations'
        }),

				reader: new Ext.data.JsonReader({
					totalProperty: 'results', 
					root: 'rows',							
					fields: [
					{name: 'id'},
					{name: 'ygid'},
					{name: 'ygxm',	type: 'string'},
					{name: 'mobile',	type: 'string'},
					{name: 'icon',	type: 'string'},
					{name: 'lon_lat',	type: 'string'},
					{name: 'update_at',	type: 'date', dateFormat: 'Y-m-d H:i:s'}
 					]		 
				}),
				sortInfo:{field: 'id', direction: "ASC"}
    });

		device_store.load();
		
		var simple = new Ext.Panel({
        width: 800,
				height: 500,
				layout: 'fit',
				plain: true,
        items: [
		        {
		            xtype: 'grid',
				        store: device_store,
				        width: 600,
				        title: '设备管理',
								layout: 'fit',
				        columns: [
										{ id: 'id', header: "序号", dataIndex: 'id', hidden: true, width: 25,sortable: true},
										{ header: "员工姓名",   dataIndex: 'ygxm',  width: 80, sortable:true},
										{ header: "手机号",    dataIndex: 'mobile',  width: 160, sortable:true},
										{ header: "位置",   	dataIndex: 'lon_lat', 		width: 200, sortable: true},
										{ header: "更新时间",   dataIndex: 'update_at', renderer : Ext.util.Format.dateRenderer('Y-m-d H:i:s'),	width: 150, sortable: true}
				        ]
		        }
        ]
    });

    simple.render('device-grid');
});